package com.aclyyx.mi.display;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class DisplayThread extends Thread {

	private DisplayView view;
	private SurfaceHolder holder;
	
	public DisplayThread(DisplayView view, SurfaceHolder holder) {
		this.view = view;
		this.holder = holder;
	}
	
	public void run() {
		Canvas canvas = null;
		while (view.runFlag) {

			canvas = holder.lockCanvas();
			synchronized (holder) {
				try {
					view.onDraw(canvas);
				} catch (Exception e) {
					
				} finally {
					if (canvas != null) {
						holder.unlockCanvasAndPost(canvas);
					}
				}
			
				try {Thread.sleep(35);} 
				catch (InterruptedException e) {}
			}
		}
	}
}
